package com.shjy.client.delegate;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.webkit.JavascriptInterface;

import com.shjy.client.util.Const;

/**
 * Created by wed on 2017/5/20.
 */

public class MainWebviewDelegate extends BaseWebviewDelegate {

    public MainWebviewDelegate(Context context, Handler handler) {
        super(context, handler);
    }

    /**
     * 马上叫车／预约叫车
     * @param type
     */
    @JavascriptInterface
    public void callCar(String type) {

        String url = Const.URL_PREFIX + "customer/order/select_track.html?callType=" + type + "&fromType=INDEX";
        sendMessage(url);
    }

    /**
     * 我的订单
     */
    @JavascriptInterface
    public void myOrder() {

        String url = Const.URL_PREFIX + "customer/order/order_list.html";
        sendMessage(url);
    }

    /**
     * 订单列表页跳转到订单详细页
     * @param waybillId
     */
    @JavascriptInterface
    public void goDetail(String waybillId) {

        String url = Const.URL_PREFIX + "customer/order/order_detail.html?waybillId=" + waybillId;
        sendMessage(url);
    }

    /**
     * 订单列表页点击评价，跳转到评价页面
     * @param waybillId
     */
    @JavascriptInterface
    public void goOrderEvaluation(String waybillId) {

        String url = Const.URL_PREFIX + "customer/order/order_ok.html?waybillId=" + waybillId;
        sendMessage(url);
    }

    /**
     * 订单列表页点击支付，跳转到支付页
     * @param waybillId
     */
    @JavascriptInterface
    public void goFeeDetail(String waybillId) {

        String url = Const.URL_PREFIX + "customer/order/price_detail.html?waybillId=" + waybillId;
        sendMessage(url);
    }

    private void sendMessage(String url) {

        Message message = new Message();
        message.what = 9;
        message.obj = url;

        mHandler.sendMessage(message);
    }
}
